package pers.course.exam;

import java.util.*;

public class WordPattern {
    public static boolean wordPattern(String pattern, String s) {
        char[] chars = pattern.toCharArray();
        String[] s1 = s.split(" ");
        if (chars.length != s1.length) {
            return false;
        }
        Map<Character, String> map = new HashMap<>();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < chars.length; i++) {
            if (map.get(chars[i]) == null) {
                if (set.contains(s1[i])) {
                    return false;
                }
                map.put(chars[i], s1[i]);
                set.add(s1[i]);
            } else {
                if (!map.get(chars[i]).equals(s1[i])) {
                    return false;
                }
            }
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String pattern = in.nextLine();
        String s = in.nextLine();
        if (wordPattern(pattern, s)) {
            System.out.println("true");
        } else {
            System.out.println("false");
        }
    }
}